<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>翻转数组 [1,2,3,4,5] =>[5,4,3,2,1]</title>
</head>

<body>
    <script>
        var arr = [1, 2, 3, 4, 5,"Ho","洲洲","zhi","haha"];
        var newArr = [];
        // for (var i = arr.length - 1; i >= 0; i--) {
        //     newArr.push(arr[i]);
        // }
        for (var i = 0, len = arr.length; i < len; i++) {
            newArr.unshift(arr[i]);
        }

        for (var i = 0, len = arr.length, temp = 0; i < len / 2; i++) {
            temp = arr[i];
            arr[i] = arr[len - i - 1];
            arr[arr.length - i - 1] = temp;
        }
        console.log(newArr);
        console.log(arr);
    </script>
</body>

</html>